//app.js
App({
  onLaunch: function() {
    if (!wx.getStorageSync('token')){
      wx.reLaunch({
        url: '/pages/authorization/authorization'
      })
    }
  },
  req: function(url, data, method = 'GET', callBack) {
    new Promise((resolve, reject) => {
      wx.request({
        url: this.globalData.api + url,
        data: data,
        method: method,
        header: {
          'Authorization': wx.getStorageSync('token')
        },
        success(res) {
          if (res.data.code == 200) {
            resolve(res)
          } else {
            reject(res)
          }
        }
      })
    }).then(res => {
      callBack(res)
    }).catch(res => {
      callBack(res)
    })
  },


  globalData: {
    api: 'https://yiqi.lsoon.cn/clothing/api/',
    // api:'http://192.168.0.114:8080/api/',
    imgApi: 'https://yiqi.lsoon.cn/clothing',
    // imgApi:'http://192.168.0.114:8080',
    clothingStyleList: [],
    fabricList: [], //面料
    auxiliaryFabricList: [], //辅料
    XfabricList: '',
    XauxiliaryFabricList: ''
  }
})